﻿{include file="/public/header" /}
<div class="content-wraper full">
    <div class="tabs-link-wrap" level="first">
        <div class="tabs-link-scroll">
            <!--{if ($nav ?? NULL)}-->
            <!--{foreach $nav as $key => $row}-->
            <a href="{$_G['_mca_'] ?? ''}/nkey/{$key ?? ''}" {if $nkey==$key}class="active"{/if}>{$row['title'] ?? ''}</a>
            <!--{/foreach}-->
            <!--{/if}-->
        </div>
    </div>
    <div class="tools-bar">
        <!--{if $nkey == 'index'}-->
        <a data-key="edit"><i class="fa fa-edit"></i> 编辑</a>
        <a data-key="lock"><i class="fa fa-lock"></i> 停职|恢复</a>
        <a data-key="delete"><i class="fa fa-trash"></i> 离职</a>
        <a data-key="vip"><i class="fa fa-heart"></i> 会员VIP</a>        
        <!--{/if}-->
        <!--{if $nkey == 'apply'}-->
        <a data-key="pass"><i class="fa fa-check"></i> 通过</a>
        <a data-key="refuse"><i class="fa fa-close"></i> 拒绝</a>
        <!--{/if}-->
    </div>
    <div class="normal-line"></div>
    <div class="search_wraper" style="min-height: 51px;">
        <form class="normal_form search_form" onsubmit="return false;">
            <div class="condition" onscroll="Core.scrolling(this)">
            </div>
            <div class="row form-footer-bar">
                <button class="btn" type="reset" role="btn-cancel">重置</button>
                <button r-button class="btn btn-primary search-btn" type="submit" role="btn-submit">搜索</button>
                <button r-button style="display: none;" class="btn switch_search filter">展开搜索条件<i class="fa fa-angle-down"></i></button>
                <div style="margin: 10px 0 -10px;"><a class="search_close"><i class="fa fa-angle-up"></i>收起</a></div>
            </div>
        </form>
    </div>
    <div class="table_box">
        <table class="table_main" id="datalist"></table>
    </div>
</div>
<script type="text/javascript">
Core.Easyui.FieldColumn = [
	{field:'gender',title:'性别',width:150,align:'center',formatter:function(value,row,index){
		return ['-','男','女'][value] || '';
	}},
    {field:'teamname',title:'小组',width:100,align:'center'},
    {field:'gradename',title:'服务等级',width:130,align:'center'},
    {field:'attnname',title:'考勤方案',width:100,align:'center'},
    {field:'state',title:'状态',width:150,align:'center',formatter:function(value,row,index){
		return ['-','<i class="fa fa-check" style="color:green"></i>','试用','<span style="color:red">停职</span>'][value] || '';
	}},
    {field:'viptime',title:'VIP到期时间',width:120,align:'center'},
    {field:'lastpost',title:'最后更新时间',width:150,align:'center'},
    {if $nkey == 'index'}
    {field:'entrytime',title:'入职时间',width:150,align:'center'},
    {else if $nkey == 'apply'}
    {field:'dateline',title:'申请时间',width:150,align:'center'},
    {/if}
    {field:'mid',title:'MID',width:120,align:'center'},
];
Core.Easyui.FrozenColumn = [
    {field:'ck',checkbox:true,width:30},
    {field:'uid',title:'UID',width:80,align:'center'},    
    //{field:'deptname',title:'部门',width:130,align:'center'},    
    {field:'nickname',title:'花名',width:320,align:'left',search: true, nowsearch: true, searchtype: 'input'},
    {field:'mobile',title:'手机号',width:120,align:'center',search: true, nowsearch: false, searchtype: 'input'},
];
Core.Easyui.init($("#datalist"), {
    url: "{$_G['_mc_'] ?? ''}/ajax/nkey/{$nkey ?? ''}",
    idField: "uid",
    fitColumns: false,
    singleSelect : true,
    columns: [Core.Easyui.FieldColumn],
    frozenColumns: [Core.Easyui.FrozenColumn],
    pageSize: 50,
    onDblClickRow: function (index,row){
        Core.Sys.Action('pop',row);
    },
},$(".search_form"));

Core.Sys.Action = function(Tkey,row){
    switch(Tkey){
        {if $nkey == 'index'}
        case 'edit':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){Core.Dialog.msg('请选择需要操作的员工数据！');return;}
            Core.Sys.Action('pop',row);
        break;
        case 'pop':
            if (!row) return;
            Core.Dialog.open({'title': '编辑'+(row.nickname || ''),'width': '500px','height': '450px','url': "{$_G['_mc_'] ?? ''}/edit/uid/"+row.uid});
        break;
        case 'lock':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){Core.Dialog.msg('请选择需要操作的员工数据！');return;}
		    Core.Dialog.confirm({'title':row.state!=3 ? '员工停职' : '员工恢复','content':row.state!=3 ? '确认该员工停职吗，停职后无法使用系统！' : '确定该员工恢复使用系统吗','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/member/pkey/"+(row.state!=3 ? 'lock' : 'unlock')+"/uid/"+row.uid+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;
        case 'delete':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){Core.Dialog.msg('请选择需要离职的数据！');return;}
		    Core.Dialog.confirm({'title':'员工离职','content':'确认该员工要离职吗？','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/member/pkey/delete/uid/"+row.uid+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;
        case 'vip':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){ Core.Dialog.msg('请选择会员'); return;}
            Core.Dialog.open({'title': '会员VIP','width': '500px','height': '320px','url': "{$_G['_mc_'] ?? ''}/vip/uid/"+row.uid});
        break;
        {else if $nkey == 'apply'}
        case 'pass':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){ Core.Dialog.msg('请选择要审核的数据'); return;}
            Core.Dialog.confirm({'title':'确定通过','content':'确认审核通过该数据吗？','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/apply/pkey/pass/uid/"+row.uid+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;
        case 'refuse':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){ Core.Dialog.msg('请选择要拒绝的数据'); return;}
            Core.Dialog.confirm({'title':'驳回申请','content':'驳回申请该申请数据吗？','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/apply/pkey/refuse/uid/"+row.uid+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;
        {/if}
    }
    return;
}
/**搜索 */
var Table_Filters = Core.Search.searchArray();
var filterType = Core.Search.typeList();
//var rsourceUrl = "/index/ajax/index"; //搜索字段基础数据
//var regionUrl = "/index/ajax/district/level/"; //城市搜索字段
Core.Search.initFilter(null,null);

$(document).ready(function(){
    $('.tools-bar').find('a[data-key]').on('click',function(){
        var Tkey = $(this).attr('data-key');
        if (!Core.rule('key',Tkey)) return false;
        Core.Sys.Action(Tkey);
    });
});
</script>
{include file="/public/footer" /}